package Domain.Player;

import Domain.GameGrid;
import Domain.MonteCarlo;
import Domain.Player.Disc;
import Domain.Square;
import java.awt.Color;
import java.io.Serializable;

/**
 * Computer represents a Computer player
 */
public class Computer extends Player implements Serializable {

    /**
     * Used for getting a good move.
     */
    private int aiType;
    private MonteCarlo monteCarlo;

    /**
     * Constructor.
     */
    public Computer(String name, Disc discID, Color discColor) {
        super(name, discID, discColor);
        this.monteCarlo = new MonteCarlo(discID, super.getName());
        // setAIType(AI.AI_MINMAX);
        //setAIType(AI.AI_HASHMAP);
    }

    public int getAIType() {
        return aiType;
    }

    @Override
    public Square getNextMove(GameGrid gameGrid) {
        return monteCarlo.getNextMove(gameGrid);
    }

    public int getNrOfEvaluatedMoves() {
        return 0;
    }

    @Override
    public PlayerType getType() {
        return PlayerType.COMPUTER;
    }

    public int getScoreForMove() {
        return 0;//((AI_Minimax)ai).getMoveScore();
    }

    @Override
    public String toString() {
        return super.toString()
                + ", type = computer, color = " + getDiscColor();
    }

    @Override
    public void updateHash(double reward) {
        if (reward == -1337) {
            monteCarlo.saveHashMapToFile();
        } else if(reward == -101){
            // decrease exploration
        }else {
            monteCarlo.updateStates(reward);
        }
    }
}
